<?php
class DichvuksController extends AppController {
	var $name = 'Dichvuks';
	var $components = array('Common','Session','Email', 'RequestHandler','Redirect');

    //function beforeFilter(){ 
        //parent::beforeFilter(); 
        //$this->Auth->allow('index','view','dangky'); 
    //}

    function ds() {
	 		$this->Dichvuk->recursive = 0;
	 		$this->set('dichvuks', $this->paginate());
	 	}
	 function index() {
	 		$this->Dichvuk->recursive = 0;
	 		$this->set('dichvuks', $this->paginate());
	 	}

	 	function view($id = null) {
	 		if (!$id) {
	 			$this->Redirect->flashWarning(__('Không Tồn Tại Dịch Vụ', array('action' =>
				'index')));
	 			//$this->redirect(array('action' => 'index'));
	 		}
	 		$this->set('dichvuk', $this->Dichvuk->read(null, $id));
	 	}

	 	function add() {
	 		if (!empty($this->data)) {
	 			$this->Dichvuk->create();
	 			if ($this->Dichvuk->save($this->data)) {
	 				$this->Session->setFlash(__('Thông tin đã lưu', true));
	 				$this->redirect(array('action' => 'ds'));
	 			} else {
	 				$this->Session->setFlash(__('Thông tin không thể lưu.', true));
	 			}
	 		}
	 	}

	 	function edit($id = null) {
	 		if (!$id && empty($this->data)) {
	 			$this->Session->setFlash(__('Invalid dichvuk', true));
	 			$this->redirect(array('action' => 'index'));
	 		}
	 		if (!empty($this->data)) {
	 			if ($this->Dichvuk->save($this->data)) {
	 				$this->Session->setFlash(__('The dichvuk has been saved', true));
	 				$this->redirect(array('action' => 'index'));
	 			} else {
	 				$this->Session->setFlash(__('The dichvuk could not be saved. Please, try again.', true));
	 			}
	 		}
	 		if (empty($this->data)) {
	 			$this->data = $this->Dichvuk->read(null, $id);
	 		}
	 	}

	 	function delete($id = null) {
	 		if (!$id) {
	 			$this->Session->setFlash(__('Invalid id for dichvuk', true));
	 			$this->redirect(array('action'=>'index'));
	 		}
	 		if ($this->Dichvuk->delete($id)) {
	 			$this->Session->setFlash(__('Dichvuk deleted', true));
	 			$this->redirect(array('action'=>'index'));
	 		}
	 		$this->Session->setFlash(__('Dichvuk was not deleted', true));
	 		$this->redirect(array('action' => 'index'));
	 	}
        
        function dangky($id)
		{
				
					$this->Dichvuk->set($this->data);
					//lay thong tin cua san pham
					$this->set('ttdvu',$this->Dichvuk->find('all',array('conditions'=>array('id'=>$id)))); 
                    $this->set('dv',$this->Dichvuk->find('all'));
                    //$this->set(compact('dichvuks'));
				
			}
	
    //----------------------------
  /*  function index()
		{ 
		$this->set('var_dv',$this->Dichvuk->find('all'));
		}
   function dichvu()
		{
			if(isset($session))
			{
				$this->redirect(array('action'=>'../users/login'));
			}
			else
			{
				$this->set('dv',$this->Dichvuk->find('all'));	
			}
		}
    function themdichvu(){}
    function tdvthanhcong()
		{
						debug($this->data);
                        $record['Dichvuk']['tendv']=$this->data['Dichvuk']['tendv'];
                        $record['Dichvuk']['ghichudv']=$this->data['Dichvuk']['ghichudv'];
                        $record['Dichvuk']['dongia1trang']=$this->data['Dichvuk']['dongia1trang'];
                        $this->Dichvuk->save($record);
		}
  function suadichvu($id)
		{
				if($id=="")
				{
				}
				else
				{
					$this->Dichvuk->set($this->data);
					//lay thong tin cua san pham
					$this->set('ttdvu',$this->Dichvuk->find('all',array('conditions'=>array('id'=>$id))));
				
				}
        }
  function capnhat()
		{   
					debug($this->data);
                    $record['Dichvuk']['id']=$this->data['Dichvuk']['id'];
                    $record['Dichvuk']['tendv']=$this->data['Dichvuk']['tendv'];
                    $record['Dichvuk']['ghichudv']=$this->data['Dichvuk']['ghichudv'];
                    $record['Dichvuk']['dongia1trang']=$this->data['Dichvuk']['dongia1trang'];
					$this->Dichvuk->save($record);
		}
    
    function xoadichvu($id)
		{
			     printf($id);
                
				$this->Dichvuk->delete($id);
			
		}
    function dangky($id)
		{
				if($id=="")
				{
                    
				}
				else
				{
					$this->Dichvuk->set($this->data);
					//lay thong tin cua san pham
					$this->set('ttdvu',$this->Dichvuk->find('all',array('conditions'=>array('id'=>$id)))); 
                    $this->set('dv',$this->Dichvuk->find('all'));
                    //$this->set(compact('dichvuks'));
				}
			}
   
   function chitiet($id) {
	 		if (!$id) {
	 			$this->Session->setFlash(__('Invalid dichvuk', true));
	 			$this->redirect(array('action' => 'index'));
	 		}
	 		$this->set('dichvuk', $this->Dichvuk->read(null, $id));
	 	}
        //----------------------------
     */
}